#ifndef CLIENT_TCP_H
#define CLIENT_TCP_H
#include "ClientProtocol.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#define PORT_NUMBER 7331

/*!
  TCP implementation of abstract ClientProtocol
*/
class ClientTCP: public ClientProtocol
{
private:
	bool connected;
	int sockfd;
	struct sockaddr_in serv_addr;
	struct hostent *server;
	void *parameters;
	int parameterCount;

public:
        /*!
          Default constructor
        */
	ClientTCP();
	ClientTCP(int);

        /*!
          Connects to the server
          @param[in] QString server ip
        */
	void connect(QString);

        /*!
          Sending message to the server
          @param[in] command type
          @param[in] command parameters num
          @param[in] command parameters
        */
	void sendToServer(int,int, void*);

        /*!
          Receive command from the client
        */
        int receive();

        /*!
          Receive connection data(for now char* robotname)
        */
	char* receiveConnect();

        /*!
          Closing the socket
        */
	void close();

        /*!
          Checks if socket is open
        */
	bool isOpen();

        /*!
          Checks if connection is avalaible
        */
	bool isConnected();

	void initServer();
	ClientTCP* acceptConnection();
	void sendToClient(int);
	void sendRobotName(const char*);
	int getParameterCount();
	void* getParameters();
};

#endif
